//
//  YLMonthlyBillHeader.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/25.
//  Copyright © 2017年 she1323. All rights reserved.
//  月账单头

#import "YLMonthlyBillHeader.h"
#import <Masonry.h>
#import "YLMonthlyBillHeaderTopView.h"
#import "YLMonthlyBillHeaderCenterView.h"
#import "YLMonthlyBillHeaderBottomView.h"


@interface YLMonthlyBillHeader ()

@property (nonatomic, weak) YLMonthlyBillHeaderCenterView *centerView;

@property (nonatomic, weak) YLMonthlyBillHeaderBottomView *bottomView;
@end

@implementation YLMonthlyBillHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setUpUI
{
    __weak typeof(self) weakSelf = self;
    YLMonthlyBillHeaderTopView *topView = [[YLMonthlyBillHeaderTopView alloc] init];
    [self addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.left.mas_equalTo(weakSelf);
        make.height.mas_equalTo(44);
    }];
    
    YLMonthlyBillHeaderCenterView *centerView = [[YLMonthlyBillHeaderCenterView alloc] init];
    _centerView = centerView;
    [self addSubview:centerView];
    [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.mas_equalTo(weakSelf);
        make.height.mas_equalTo(40);
        make.top.mas_equalTo(topView.mas_bottom);
    }];
    
    YLMonthlyBillHeaderBottomView *bottomView = [[YLMonthlyBillHeaderBottomView alloc] init];
    _bottomView = bottomView;
    [self addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(150);
        make.left.right.mas_equalTo(weakSelf);
        make.top.mas_equalTo(centerView.mas_bottom);
    }];
}

- (void)setType:(YLMonthlyBillHeaderCenterViewType)type
{
    _type = type;
    _centerView.type = type;
    if (type == YLMonthlyBillHeaderCenterViewTypeExpectedReturn) {
        _bottomView.type = YLMonthlyBillHeaderBottomViewTypeExpectedReturn;
    } else if (type == YLMonthlyBillHeaderCenterViewTypeHoldingAssets) {
        _bottomView.type = YLMonthlyBillHeaderBottomViewTypeHoldingAssets;
    }
    
}

@end
